home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / javax / accessibility / AccessibleComponent.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  9.2 KB  |  306 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)AccessibleComponent.java    1.6 98/08/26
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package javax.accessibility;
  16.  
  17. import java.awt.*;
  18. import java.awt.event.*;
  19.  
  20. /**
  21.  * The AccessibleComponent interface should be supported by any object 
  22.  * that is rendered on the screen.  This interface provides the standard 
  23.  * mechanism for an assistive technology to determine and set the 
  24.  * graphical representation of an object.  Applications can determine
  25.  * if an object supports the AccessibleComponent interface by first
  26.  * obtaining its AccessibleContext (see {@link AccessibleAccessible})
  27.  * and then calling the
  28.  * {@link AccessibleContext#getAccessibleComponent} method.
  29.  * If the return value is not null, the object supports this interface.
  30.  *
  31.  * @see Accessible
  32.  * @see Accessible#getAccessibleContext
  33.  * @see AccessibleContext
  34.  * @see AccessibleContext#getAccessibleComponent
  35.  *
  36.  * @version     1.6 08/26/98 21:14:08
  37.  * @author    Peter Korn
  38.  * @author    Hans Muller
  39.  * @author      Willie Walker
  40.  */
  41. public interface AccessibleComponent {
  42.  
  43.     /**
  44.      * Get the background color of this object.
  45.      *
  46.      * @return the background color, if supported, of the object; 
  47.      * otherwise, null
  48.      * @see #setBackground
  49.      */
  50.     public Color getBackground();
  51.  
  52.     /**
  53.      * Set the background color of this object.
  54.      *
  55.      * @param c the new Color for the background
  56.      * @see #setBackground
  57.      */
  58.     public void setBackground(Color c);
  59.  
  60.     /**
  61.      * Get the foreground color of this object.
  62.      *
  63.      * @return the foreground color, if supported, of the object; 
  64.      * otherwise, null
  65.      * @see #setForeground
  66.      */
  67.     public Color getForeground();
  68.  
  69.     /**
  70.      * Set the foreground color of this object.
  71.      *
  72.      * @param c the new Color for the foreground
  73.      * @see #getForeground
  74.      */
  75.     public void setForeground(Color c);
  76.  
  77.     /**
  78.      * Get the Cursor of this object.
  79.      *
  80.      * @return the Cursor, if supported, of the object; otherwise, null
  81.      * @see #setCursor
  82.      */
  83.     public Cursor getCursor();
  84.  
  85.     /**
  86.      * Set the Cursor of this object.
  87.      *
  88.      * @param c the new Cursor for the object
  89.      * @see #getCursor
  90.      */
  91.     public void setCursor(Cursor cursor);
  92.  
  93.     /**
  94.      * Get the Font of this object.
  95.      *
  96.      * @return the Font,if supported, for the object; otherwise, null
  97.      * @see #setFont
  98.      */
  99.     public Font getFont();
  100.  
  101.     /**
  102.      * Set the Font of this object.
  103.      *
  104.      * @param f the new Font for the object
  105.      * @see #getFont
  106.      */
  107.     public void setFont(Font f);
  108.  
  109.     /**
  110.      * Get the FontMetrics of this object.
  111.      *
  112.      * @param f the Font
  113.      * @return the FontMetrics, if supported, the object; otherwise, null
  114.      * @see #getFont
  115.      */
  116.     public FontMetrics getFontMetrics(Font f);
  117.  
  118.     /**
  119.      * Determine if the object is enabled.  Objects that are enabled
  120.      * will also have the AccessibleState.ENABLED state set in their
  121.      * AccessibleStateSet.
  122.      *
  123.      * @return true if object is enabled; otherwise, false
  124.      * @see #setEnabled
  125.      * @see AccessibleContext#getAccessibleStateSet
  126.      * @see AccessibleState#ENABLED
  127.      * @see AccessibleStateSet
  128.      */
  129.     public boolean isEnabled();
  130.  
  131.     /**
  132.      * Set the enabled state of the object.
  133.      *
  134.      * @param b if true, enables this object; otherwise, disables it 
  135.      * @see #isEnabled
  136.      */
  137.     public void setEnabled(boolean b);
  138.  
  139.     /**
  140.      * Determine if the object is visible.  Note: this means that the
  141.      * object intends to be visible; however, it may not be
  142.      * showing on the screen because one of the objects that this object
  143.      * is contained by is currently not visible.  To determine if an object is
  144.      * showing on the screen, use isShowing().
  145.      * <p>Objects that are visible will also have the 
  146.      * AccessibleState.VISIBLE state set in their AccessibleStateSet.
  147.      *
  148.      * @return true if object is visible; otherwise, false
  149.      * @see #setVisible
  150.      * @see AccessibleContext#getAccessibleStateSet
  151.      * @see AccessibleState#VISIBLE
  152.      * @see AccessibleStateSet
  153.      */
  154.     public boolean isVisible();
  155.  
  156.     /**
  157.      * Set the visible state of the object.
  158.      *
  159.      * @param b if true, shows this object; otherwise, hides it 
  160.      * @see #isVisible
  161.      */
  162.     public void setVisible(boolean b);
  163.  
  164.     /**
  165.      * Determine if the object is showing.  This is determined by checking
  166.      * the visibility of the object and visibility of the object ancestors.
  167.      * Note: this
  168.      * will return true even if the object is obscured by another (for example,
  169.      * it to object is underneath a menu that was pulled down).
  170.      *
  171.      * @return true if object is showing; otherwise, false
  172.      */
  173.     public boolean isShowing();
  174.  
  175.     /** 
  176.      * Checks whether the specified point is within this object's bounds,
  177.      * where the point's x and y coordinates are defined to be relative to the
  178.      * coordinate system of the object. 
  179.      *
  180.      * @param p the Point relative to the coordinate system of the object
  181.      * @return true if object contains Point; otherwise false
  182.      * @see #getBounds
  183.      */
  184.     public boolean contains(Point p);
  185.  
  186.     /** 
  187.      * Returns the location of the object on the screen.
  188.      *
  189.      * @return location of object on screen; null if this object
  190.      * is not on the screen
  191.      * @see #getBounds
  192.      * @see #getLocation
  193.      */
  194.     public Point getLocationOnScreen();
  195.  
  196.     /** 
  197.      * Gets the location of the object relative to the parent in the form 
  198.      * of a point specifying the object's top-left corner in the screen's 
  199.      * coordinate space.
  200.      *
  201.      * @return An instance of Point representing the top-left corner of the 
  202.      * objects's bounds in the coordinate space of the screen; null if
  203.      * this object or its parent are not on the screen
  204.      * @see #getBounds
  205.      * @see #getLocationOnScreen
  206.      */
  207.     public Point getLocation();
  208.  
  209.     /** 
  210.      * Sets the location of the object relative to the parent.
  211.      * @param p the new position for the top-left corner
  212.      * @see #getLocation
  213.      */
  214.     public void setLocation(Point p);
  215.  
  216.     /** 
  217.      * Gets the bounds of this object in the form of a Rectangle object. 
  218.      * The bounds specify this object's width, height, and location
  219.      * relative to its parent. 
  220.      *
  221.      * @return A rectangle indicating this component's bounds; null if 
  222.      * this object is not on the screen.
  223.      * @see #contains
  224.      */
  225.     public Rectangle getBounds();
  226.  
  227.     /** 
  228.      * Sets the bounds of this object in the form of a Rectangle object. 
  229.      * The bounds specify this object's width, height, and location
  230.      * relative to its parent.
  231.      *    
  232.      * @param r rectangle indicating this component's bounds
  233.      * @see #getBounds
  234.      */
  235.     public void setBounds(Rectangle r);
  236.  
  237.     /** 
  238.      * Returns the size of this object in the form of a Dimension object. 
  239.      * The height field of the Dimension object contains this objects's
  240.      * height, and the width field of the Dimension object contains this 
  241.      * object's width. 
  242.      *
  243.      * @return A Dimension object that indicates the size of this component; 
  244.      * null if this object is not on the screen
  245.      * @see #setSize
  246.      */
  247.     public Dimension getSize();
  248.  
  249.     /** 
  250.      * Resizes this object so that it has width and height. 
  251.      *    
  252.      * @param d - The dimension specifying the new size of the object. 
  253.      * @see #getSize
  254.      */
  255.     public void setSize(Dimension d);
  256.  
  257.     /**
  258.      * Returns the Accessible child, if one exists, contained at the local 
  259.      * coordinate Point.
  260.      *
  261.      * @param p The point relative to the coordinate system of this object.
  262.      * @return the Accessible, if it exists, at the specified location; 
  263.      * otherwise null
  264.      */
  265.     public Accessible getAccessibleAt(Point p);
  266.  
  267.     /**
  268.      * Returns whether this object can accept focus or not.   Objects that 
  269.      * can accept focus will also have the AccessibleState.FOCUSABLE state 
  270.      * set in their AccessibleStateSet.
  271.      *
  272.      * @return true if object can accept focus; otherwise false
  273.      * @see AccessibleContext#getAccessibleStateSet
  274.      * @see AccessibleState#FOCUSABLE
  275.      * @see AccessibleState#FOCUSED
  276.      * @see AccessibleStateSet
  277.      */
  278.     public boolean isFocusTraversable();
  279.  
  280.     /**
  281.      * Requests focus for this object.  If this object cannot accept focus,
  282.      * nothing will happen.  Otherwise, the object will attempt to take
  283.      * focus.
  284.      * @see #isFocusTraversable
  285.      */
  286.     public void requestFocus();
  287.  
  288.     /**
  289.      * Adds the specified focus listener to receive focus events from this 
  290.      * component. 
  291.      *
  292.      * @param l the focus listener
  293.      * @see #removeFocusListener
  294.      */
  295.     public void addFocusListener(FocusListener l);
  296.  
  297.     /**
  298.      * Removes the specified focus listener so it no longer receives focus 
  299.      * events from this component.
  300.      *
  301.      * @param l the focus listener
  302.      * @see #addFocusListener
  303.      */
  304.     public void removeFocusListener(FocusListener l);
  305. }
  306.